package androidx.preference;

import android.content.DialogInterface;
import android.os.Bundle;
import androidx.appcompat.app.b;

public class c extends f {
    int x;
    private CharSequence[] y;
    private CharSequence[] z;

    class a implements DialogInterface.OnClickListener {
        a() {
        }

        public void onClick(DialogInterface dialogInterface, int i) {
            c cVar = c.this;
            cVar.x = i;
            cVar.onClick(dialogInterface, -1);
            dialogInterface.dismiss();
        }
    }

    private ListPreference s() {
        return (ListPreference) l();
    }

    public static c t(String str) {
        c cVar = new c();
        Bundle bundle = new Bundle(1);
        bundle.putString("key", str);
        cVar.setArguments(bundle);
        return cVar;
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (bundle == null) {
            ListPreference s = s();
            if (s.M0() == null || s.O0() == null) {
                throw new IllegalStateException("ListPreference requires an entries array and an entryValues array.");
            }
            this.x = s.L0(s.P0());
            this.y = s.M0();
            this.z = s.O0();
            return;
        }
        this.x = bundle.getInt("ListPreferenceDialogFragment.index", 0);
        this.y = bundle.getCharSequenceArray("ListPreferenceDialogFragment.entries");
        this.z = bundle.getCharSequenceArray("ListPreferenceDialogFragment.entryValues");
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putInt("ListPreferenceDialogFragment.index", this.x);
        bundle.putCharSequenceArray("ListPreferenceDialogFragment.entries", this.y);
        bundle.putCharSequenceArray("ListPreferenceDialogFragment.entryValues", this.z);
    }

    public void p(boolean z2) {
        int i;
        if (z2 && (i = this.x) >= 0) {
            String charSequence = this.z[i].toString();
            ListPreference s = s();
            if (s.b(charSequence)) {
                s.R0(charSequence);
            }
        }
    }

    /* access modifiers changed from: protected */
    public void q(b.a aVar) {
        super.q(aVar);
        aVar.r(this.y, this.x, new a());
        aVar.p((CharSequence) null, (DialogInterface.OnClickListener) null);
    }
}
